<?php
/**
 * @brief DB class.
 * 
 * This class is used to connect to a database.
 * 
 * @license		http://www.gnu.org/licenses/gpl-3.0.txt GNU General Public License
 * @copyright	2007 David Singer
 * @author		David Singer <david@ramaboo.com>
 * @version		1.0.0
 */

class DB {
	
	/**
	 * @brief Connects to a database.
	 * 
	 * This function is used to connect to a database, in this case <a href="http://www.mysql.com/">MySQL 5</a>.
	 * You will need to set \c DB_CONNECTION_STRING, \c DB_USERNAME, and \c DB_PASSWORD in the PATH_TO_EXTBIND/includes/config.php file.
	 * 
	 * @return PDO object.
	 * 
	 * @code
	 * $dbh = DB::connect();
	 * @endcode
	 */
	static function connect() {
		try {
			$dbh = new PDO(DB_CONNECTION_STRING, DB_USERNAME, DB_PASSWORD, array(PDO::ATTR_PERSISTENT => true));
			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
		} catch (Exception $e) {
			trigger_error($e->getMessage(), E_USER_ERROR);
			return false;
		}
		return $dbh;
	}
}
?>